/**
 * 
 */
package com.jinmei.web.action;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.interceptor.ServletRequestAware;

import com.jinmei.model.User;
import com.jinmei.utils.JinmeiConsts;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

/**
 * @author richard
 *
 */
public class BaseAction extends ActionSupport implements ServletRequestAware {

	private static final long serialVersionUID = 1L;
	
	protected String user_sessionid;
	protected String username;
	protected HttpServletRequest request;
	

	/**
	 * used for passing user_sessionid to jsp page
	 * 
	 * @param user_sessionid
	 */
	public void setUser_sessionid(String user_sessionid) {
		this.user_sessionid = user_sessionid;
	}
	
	public String getUser_sessionid() {
		return user_sessionid;
	}
	
	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	@Override
	public void setServletRequest(HttpServletRequest request) {
		this.request = request;
	}
	
	public void setUserSessionIdAndUsername() {
		User user = (User) ActionContext.getContext().getSession().get(JinmeiConsts.USER);
		setUser_sessionid(user.getSessionid());
		setUsername(user.getName());
	}

}
